package com.mxpio.erp.common.equipment.entity;

import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.persistence.*;

/**
 * @Description: 入库记录
 * @Author: MxpIO
 * @Date:   2021-10-11
 * @Version: V1.0
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_EQUIPMENT_STOCK_RK_HISTORY")
@Schema(description="入库记录")
public class EquipmentStockRkHistory extends BaseEntity {
    private static final long serialVersionUID = 1L;

	/**id*/
    @Id
    @Generator
    @Column(name = "ID_", updatable = false)
    @Schema(description = "ID")
    private String id;
	/**isDel*/
    @Column(name = "IS_DEL_")
    @Schema(description = "isDel")
    private Integer isDel;
	/**版本*/
    @Column(name = "VERSION_")
    @Schema(description = "版本")
    private Integer version;
	/**本次接收数量*/
    @Column(name = "CURRENT_ACCEPT_")
    @Schema(description = "本次接收数量")
    private Integer currentAccept;
	/**入库ID*/
    @Column(name = "INBOUND_APPLY_ID_")
    @Schema(description = "入库ID")
    private String inboundApplyId;
	/**物料ID*/
    @Column(name = "MATERIALS_ID_")
    @Schema(description = "物料ID")
	@Dict(dicCode = "id",dicText = "name",dicEntity =EquipmentMaterial.class)
    private String materialsId;
	/**入库详情ID*/
    @Column(name = "INBOUD_APPLY_ITEM_ID_")
    @Schema(description = "入库详情ID")
    private String inboudApplyItemId;
	/**shelfId*/
    @Column(name = "SHELF_ID_")
    @Schema(description = "shelfId")
    private String shelfId;
	/**type*/
    @Column(name = "TYPE_")
    @Schema(description = "type")
    private Integer type;

    /**仓库*/
    @Dict(dicEntity =EquipmentStock.class, dicText = "stockName", dicCode = "id")
    @Column(name = "STOCK_ID_")
    @Schema(description = "仓库")
    private String stockId;

    /**批次号*/
    @Column(name = "BATCH_NO_")
    @Schema(description = "批次号")
    private String batchNo;

    @Column(name = "MATERIALS_NAME")
    @Schema(description = "批次号")
    private String materialsName;

    @Column(name = "MATERIALS_CODE")
    @Schema(description = "批次号")
    private String materialsCode;

    @Column(name = "MATERIALS_TYPE")
    @Schema(description = "批次号")
    private String materialsType;

    @Transient
	private String optType;

	public EquipmentStockRkHistory(EquipmentStockRkApplyItem item, int type){
	    this.isDel = 0;
	    this.version = 0;
	    this.currentAccept = item.getThisOptNum();
	    this.inboundApplyId = item.getApplyId();
	    this.materialsId = item.getMaterialsId();
	    this.inboudApplyItemId = item.getId();
	    this.type = type;
        this.batchNo = item.getBatchNo();
    }
}
